package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    Long insert(Orders order);

    List<Orders> select(Orders orders);

    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where id = #{id}")
    Orders getById(Long id);

    void update(Orders orders);

    @Select("select count(*) from orders where status = #{toBeConfirmed}")
    Integer countstatus(Integer toBeConfirmed);

    @Select("select * from orders where status=#{status} and order_time<#{time}")
    List<Orders> getTimeoutOrder(Integer status, LocalDateTime time);

    @Select("select sum(amount) from orders where order_time between #{begin} and #{end} and status=#{status}")
    Double sumByMap(Map map);
    @Select("select count(*) from user where create_time between #{begin} and #{end} ")
    boolean countuser(LocalDateTime of, LocalDateTime of1);

    Integer countOrder(LocalDateTime begin, LocalDateTime end, Integer status);
    List<GoodsSalesDTO>getSalestop10(LocalDateTime begin,LocalDateTime end);
}
